package com.wangzhen.springboot.web;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@SpringBootApplication
public class SpringbootWebApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootWebApplication.class);
    }

    @GetMapping("/login")
    public String login(@RequestParam String name, @RequestParam String pwd, HttpSession session) {
        session.setAttribute("name", "zhangsan");
        return name + " login success !";
    }

    @GetMapping("/get")
    public String get(HttpSession session) {
        session.setAttribute("name", "zhangsan");
        return "name=" + " " + session.getAttribute("name");
    }

}
